home *** CD-ROM | disk | FTP | other *** search
/ Fritz: All Fritz / All Fritz.zip / All Fritz / FILES / PROGNG_C / CUG187.LZH / TRIM.C < prev    next >
C/C++ Source or Header  |  1985-12-31  |  815b  |  27 lines

  1. /*@*****************************************************/
  2. /*@                                                    */
  3. /*@ trim - trim trailing blanks from a string.         */
  4. /*@                                                    */
  5. /*@   Usage:     trim(str);                            */
  6. /*@       where str is the string to be trimed.        */
  7. /*@                                                    */
  8. /*@   Returns a pointer to the string to allow         */
  9. /*@       function nesting.                            */
  10. /*@                                                    */
  11. /*@*****************************************************/
  12.  
  13. #define EOS '\0'
  14.  
  15. char *trim(str)
  16. char *str;
  17. {
  18.     int i;
  19.  
  20.     i=strlen(str);
  21.     while(i--)
  22.         if (str[i] != ' ')
  23.             break;
  24.     str[i+1] = EOS;
  25.     return str;
  26. }
  27.